package controller;

import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;

@RestController
public class helloWorldController {


    /**
     * hello world
     *
     * @return
     */
    @RequestMapping("/")
    public Map<String, String> home() {
        Map<String, String> result = new HashMap<>();
        result.put("xieshiwei", "xieshiwei");
        result.put("liuyan", "liuyan");
        result.put("xiemengqi", "xiemengqi");
        return result;
    }

    /**
     * Get  SpringMVC Controller
     *
     * @param cityId
     * @param userId
     * @return
     */
    @RequestMapping(path = "/{city_id}/{user_id}", method = RequestMethod.GET)
    public Map<String, String> getResultController(@PathVariable("city_id") String cityId, @PathVariable("user_id") String userId) {
        Map<String, String> result = new HashMap<>();
        result.put("cityId", cityId);
        result.put("userId", userId);
        return result;
    }

    /**
     * Get Spring Boot Controller
     *
     * @param from
     * @param size
     * @return
     */
    @GetMapping(value = "/v1/page_user")
    public Map<String, Integer> getRestFullV1(int from, int size) {
        Map<String, Integer> result = new HashMap<>();
        result.clear();
        result.put("from", from);
        result.put("size", size);
        return result;
    }

    /**
     * Get @RequestParam
     *
     * @param from
     * @param size
     * @return
     */
    @GetMapping(value = "/v2/page_user")
    public Map<Integer, Integer> getRestFullV2(@RequestParam(defaultValue = "0", name = "page") int from,
                                               @RequestParam(defaultValue = "1", name = "Size") int size) {
        Map<Integer, Integer> result = new HashMap<>();
        result.put(from, from);
        result.put(size, size);
        return result;
    }
}
